﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Xinkui.WebModel.Cache;
using Xinkui.WebModel;
using Xinkui.DataAccess.AutoGenerator;
using Xinkui.Common;
using CommonFramework.Utility;
using Xinkui.WebModel.Helper;

public partial class UserControl_UserCenter_Seller_UC_ManagerEquipment : Xinkui.WebModel.BasicControl.AccountControl {
    protected void Page_Load(object sender, EventArgs e) {
        if (!IsPostBack) {
            DataBinds();
        }
    }


    protected void DataBinds() {
        int total = 0;

        this.rptCertification.DataSource = Singleton<EquipmentInfoDataAccess>.Instance.EquipmentInfoMaintain_ListByCompany(this.BasePage.CurrentLogin.CompanyID, 100, 1, out total);
        this.rptCertification.DataBind();
        if (total <= 0) {
            this.rptCertification.Visible = false;
            this.ltNoData.Visible = true;
        }
    }


    protected void btnDel_Click(object sender, EventArgs e) {
        List<int> chkselect = WebHelper.GetFormValue<string>("chkSelect").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(u => ConvertHelper.ToType<int>(u)).ToList();

        if (chkselect.Count > 0) {
            foreach (var item in chkselect) {
                Singleton<EquipmentInfoMaintainDataAccess>.Instance.EquipmentInfoMaintain_Delete(item);
                Singleton<EquipmentInfoDataAccess>.Instance.EquipmentInfo_Delete(item);
            }
        }
        DataBinds();
        UIHelper.ShowSuucessTips("Record has deleted");
    }


    protected string BindType(object t) {
        if (t == null) { return string.Empty; }
        int type = (int)t;
        return DictCache.GetName((int)DictTypeEnum.FactoryEquipment, type);
    }
}